<template>
  <div>
    <div class="header">
      <div>行学天下</div>
      <div class="phone">
        <div><img src="../assets/yxtx/phone.png" alt="图片丢失"></div>
        <div>欢迎致电</div>
      </div>
    </div>
    <div class="content">
      <!-- 轮播 -->
      <el-carousel height="475px">
        <el-carousel-item>
          <img src="../assets/yxtx/images/picture1.jpg" width="100%" height="475px" alt="图片丢失">
        </el-carousel-item>
        <el-carousel-item>
          <img src="../assets/yxtx/images/picture2.jpg" width="100%" height="475px" alt="图片丢失">
        </el-carousel-item>
        <el-carousel-item>
          <img src="../assets/yxtx/images/picture3.jpg" width="100%" height="475px" alt="图片丢失">
        </el-carousel-item>
      </el-carousel>
      <!-- 游学项目卡片 -->
      <div class="project">
        <div class="proCard" v-for="item in projects" :key="item.id">
          <div class="photo">
            <img :src="item.figure" width="300px" height="200px" alt="图片丢失">
          </div>
          <div class="introduce">
            <div class="pro_name">{{item.name}}</div>
            <div class="pro_date">{{fmtDate(item.beginTime)}} ~ {{fmtDate(item.endTime)}}</div>
            <div class="pro_introduce">{{item.introduce}}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="footer"></div>
  </div>
</template>
<script>
import request from '../utils/request'
import moment from 'moment'
export default {
  data() {
    return {
      projects: []
    }
  },
  methods: {
    findAllProjects() {
      request.get('/index/project/pageQuery?page=1&pageSize=3').then(res => {
        // 将后台请求回来的游学项目列表赋值给projects
        this.projects = res.data.list
      })
    },
    fmtDate(date) {
      return moment(date).format('YYYY-MM-DD HH:mm:ss')
    }
  },
  created() {
    this.findAllProjects()  // 调用查询游学项目的方法
  }
}
</script>
<style scoped>
.header {
  height: 100px;
  box-shadow: 0px 0px 5px 1px #999;
  display: flex;
}
.header div:first-child {
  flex: 1;
  height: 100px;
  line-height: 100px;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
}
.header div:last-child {
  flex: 4;
  height: 100px;
  line-height: 100px;
  text-align: right;
  font-size: 18px;
  padding-right: 50px;
  display: flex;
}
.phone div:first-child {
  width: 100px;
  margin-left: 800px;
  padding-top: 15px;
}
.phone div:last-child {
  width: 100px;
}
.project {
  padding: 50px 100px;
}
.proCard {
  display: flex;
  margin-bottom: 50px;
  box-shadow: 0 0 5px 1px rgb(226, 225, 225);
}
.photo {
  width: 300px;
  height: 200px;
  border-radius: 5px;
}
.introduce {
  padding-left: 50px;
}
.pro_name {
  font-size: 18px;
  font-weight: bold;
  height: 50px;
  line-height: 50px;
}
.pro_date {
  height: 30px;
  line-height: 30px;
}
.pro_introduce {
  height: 100px;
  line-height: 25px;
}
</style>